﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using Hive.Core.Common.Shell;

namespace Hive.Core.Model
{
    /// <summary>
    /// A hive manages a collection of projects which have been checked out from a
    /// repository and their inter-dependencies.
    /// </summary>
    public interface IHive
    {
        /// <summary>
        /// Gets the hive configuration.
        /// </summary>
        HiveConfiguration Configuration { get; }

        /// <summary>
        /// Gets the name of the hive.
        /// </summary>
        string Name { get; }

        /// <summary>
        /// Gets the hive directory.
        /// </summary>
        DirectoryInfo Directory { get; }

        /// <summary>
        /// Gets the source repository associated with the hive.
        /// </summary>
        ISourceRepository SourceRepository { get; }

        /// <summary>
        /// Gets the binary repository associated with the hive.
        /// </summary>
        IBinaryRepository BinaryRepository { get; }

        /// <summary>
        /// Gets the list of all packages within the hive.
        /// </summary>
        /// <returns>The list of packages.</returns>
        IList<IPackage> GetPackages();

        /// <summary>
        /// Gets the package with the specified name.
        /// </summary>
        /// <param name="packageName">The package name.</param>
        /// <returns>The package.</returns>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="packageName"/> is null.</exception>
        IPackage GetPackage(string packageName);

        /// <summary>
        /// Finds the package branch to which the current directory belongs.
        /// </summary>
        /// <param name="currentDirectory">The current directory.</param>
        /// <param name="packageName">Set to the package name, or null if not found.</param>
        /// <param name="branchName">Set to the branch name, or null if not found.</param>
        /// <returns>True if the package branch was found.</returns>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="currentDirectory"/> is null.</exception>
        bool FindPackageBranch(DirectoryInfo currentDirectory, out string packageName, out string branchName);
    }
}
